//实时获取、设置页面宽度，
bdoySizeRander()

//获取当前登录管理员
let logId = sessionStorage.getItem('logId');
console.log(logId)

let userInfo;
//判断当前用户有没有登陆如没有登陆则跳转到登录页面
if (!logId) {
  console.log('没有登陆')
  location.href = 'wf_login.html';
}

//退出系统
$('.quit').on('click',  ()=> {
  logId = ''
  sessionStorage.setItem('logId', logId)
  // req.session.sign = false; //权限设置 --应该在登录成功之后设置；
  location.href = 'wf_login.html'
})

//时间获取
let time = nowTime()
$('.wf-log-time').text(time)
//时间刷新
setInterval(() => {
  time=nowTime()
  $('.wf-log-time').text(time)

}, 1000);

//获取当前登录用户的所有信息
gettingInformation();
//获取当前登录用户的所有信息
function gettingInformation() {
  $.ajax({
    method: 'GET',
    url: '/users/getInformation',
    data: {
      loginId: logId,
    }
  })
    .done((res) => {
      console.log('请求成功：', res.data);
      userInfo = res.data;
      //导航栏渲染
      queryAuthority()
      
      avator = userInfo.avator
      //头像渲染
      $('.wf-personal-img').css({
        background: "url("+avator+") no-repeat center /cover "
      })
    })
    .fail((err) => {
      console.log('请求失败：', err);
    });
}


//将用户的管理权限分离出来，变成数组
let administrativeAuthority=[];


//点击头像弹出选项
$('.wf-top-right-personal').on('click', ()=> {
  $('.wf-personal-list').toggle()
})
//点击菜单按钮收缩展开
$('.wf-top-left-img').on('click', navFold)
function navFold() {
  $('.wf-top-left-img').toggleClass('icon-zhankaicaidan')
  $('.wf-left-box').toggleClass('wf-left-box-toggle')
  $('.wf-log-img').toggleClass('wf-log-img-toggle')
  $('.wf-log-text').toggleClass('wf-log-text-toggle')
  $('.wf-log-time').toggleClass('wf-log-time-toggle')
  $('.a-menu').toggleClass('wf-log-text-one')
  $('.layui-nav-more').toggleClass('layui-nav-more-toggle')
  $('.layui-nav-item a').toggleClass('layui-nav-item-a-toggle')
  $('.layui-nav-item .iconfont').toggleClass('list-iconfont-change')
  $('.wf-nav-list').toggleClass('wf-nav-list-toggle')
  $('.wf-right-box').toggleClass('wf-right-box-toggle')
  $('.layui-nav-item').toggleClass('layui-nav-item-toggle');

  //折叠后点击之后收缩
  let isHavato = $('.wf-left-box')[0].className;
  let ishave=isHavato.search('toggle');
  console.log(isHavato);
  console.log(ishave);
   if (ishave != -1) {
  $('.wf-nav').on('click','dd',()=>{
      console.log('折叠点击收缩');
      $('.layui-nav-item').removeClass('layui-nav-itemed');
      return
  })
  }
  ishave=-1;


}


$('.layui-nav-child').on('click',  () =>{
  console.log('dianna')
  $('.layui-nav-item-toggle').removeClass('layui-nav-itemed')
})
